package controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import util.Response;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by lik on 2016/2/16.
 */
@Controller
public class IndexController {
    @RequestMapping(value = "/userinfo/index" , method = RequestMethod.GET)
    /*public String index(Model model,@PathVariable("name") String username){
        model.addAttribute("username","hello ricky");
        return "index";
    }*/

    /*public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("username","hello ricky");
        modelAndView.setViewName("/index");
        return modelAndView;
    }*/

    /*@RequestMapping(value = "/index/{name}" , method = RequestMethod.GET)
    public String newIndex(Model model,@PathVariable("name") String username){
        model.addAttribute("newname",username);
        return "index";
    }*/

    public Map<String,String> index(){
        Map<String,String> map = new HashMap<String,String>();
        String a="asdf";
        map.put("likai","123");
        return map;
    }

    @RequestMapping(value = "/userinfo/index" ,params = "active=testAdd", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,String> addTest(){
        System.out.println("===============");
        Map res = null;
        //res = Response.add(new HashMap<String, Object>(), 200, "reg.success");
        res = new HashMap();
        res.put("likai","likaiJson");
        return res;
    }
}
